package com.itheima.Demo01.demo05SS;

public class MyThred05S implements Runnable{
    private static int count =100;
    private static Object obj = new Object();
    @Override
    public void run() {
        while (true){
            synchronized (obj){
                if (count<=0){
//                    System.out.println("卖完了");
                    break;
                }else {
                    try {
                        Thread.sleep(1);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    count--;
                    System.out.println(Thread.currentThread().getName()+"在卖票,还剩"+count+"张");
                }
            }
        }
    }
}
